//
// Created by Castle on 2025/10/28.
//

#include<iostream>

using namespace std;

int main() {
    // int * data = new int [1000000000000000000];

    // exception
    for (size_t i{0}; i < 100;++i) {
        try {
            int * data = new int [100000000000];
        }catch (exception& ex) {
            cout << "Something went wrong: "  << ex.what() << endl;
        }
    }

    // std::nothrow
    for (size_t i{0}; i < 100;++i) {
        int * data = new(nothrow) int [100000000000];

        if (data != nullptr) {
            cout << "Data allocation" << endl;
        }else {
            cout << "Data allocation failed: " << endl;
        }

    }





    cout << "Program ending well " << endl;

    return 0;
}